package com.hkts.naturalgas.base.controller;


import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hkts.naturalgas.base.entity.RoastingonePyjone;
import com.hkts.naturalgas.base.service.IRoastingonePyjoneService;
import com.hkts.naturalgas.utils.CurveUtils;
import com.hkts.naturalgas.utils.CustomPageUtils;
import com.hkts.naturalgas.utils.Result;
import com.hkts.naturalgas.utils.ResultUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;

/**
 * @author yck
 * @since 2021-06-21
 */
@RestController
@RequestMapping("/instrumentdata/roastingonePyjone")
public class RoastingonePyjoneController {
    private final Logger logger = LoggerFactory.getLogger(RoastingonePyjoneController.class);

    @Autowired
    public IRoastingonePyjoneService iRoastingonePyjoneService;

    /**
     * 分页查询数据
     *
     * @param page              分页信息
     * @param roastingonePyjone 查询条件
     * @return
     */
    @ResponseBody
    @GetMapping("/getRoastingonePyjonePageList")
    public Result<Object> getHontUserList(Page<RoastingonePyjone> page, RoastingonePyjone roastingonePyjone) {
        return ResultUtil.data(CustomPageUtils.getCustomPage(iRoastingonePyjoneService.selectPage(page, roastingonePyjone)));
    }

    /**
     * 保存和修改公用的
     *
     * @param roastingonePyjone 传递的实体
     * @return saveOrUpdate
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/roastingonePyjoneSave")
    public Result<Object> roastingonePyjoneSave(RoastingonePyjone roastingonePyjone) {
        iRoastingonePyjoneService.saveOrUpdate(roastingonePyjone);
        return ResultUtil.success("保存成功");
    }

    /**
     * 根据id获取对象
     *
     * @param id 实体ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/roastingonePyjoneGetById")
    public Result<Object> roastingonePyjoneGetById(String id) {
        RoastingonePyjone byId = iRoastingonePyjoneService.getById(id);
        return ResultUtil.data(byId);
    }

    /**
     * 根据id删除对象
     *
     * @param id 实体ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/roastingonePyjoneDelete")
    public Result<Object> hontUserDelete(String id) {
        iRoastingonePyjoneService.removeById(id);
        return ResultUtil.success("删除成功");
    }

    /**
     * 批量删除对象
     *
     * @param item 实体集合ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/roastingonePyjoneBatchDelete")
    public Result<Object> deleteBatchIds(String item) {
        List<String> ids = (List<String>) JSON.parse(item);
        iRoastingonePyjoneService.removeByIds(ids);
        return ResultUtil.success("删除成功");
    }
   /** 功能描述:
   *  生成排烟架数据
   * @return:
   * @Author: 杨春科
   * @Date: 2021-06-26 10:52
   * @Description //TODO
   */
   @ResponseBody
   @RequestMapping(method = RequestMethod.POST, value = "/addHostoryData")
   public Result<String> addHostoryData(String startDate,String endDate) throws ParseException {
       iRoastingonePyjoneService.addHostoryData(startDate,endDate);
       return ResultUtil.data("处理成功");
   }
   /** 功能描述:
   *处理压力数据
   * @return:
   * @Author: 杨春科
   * @Date: 2021-06-30 10:07
   * @Description //TODO
   */
   @ResponseBody
   @RequestMapping(method = RequestMethod.POST, value = "/handlerPresserData")
   public Result<String> handlerPresserData(String startDate,String endDate) throws ParseException {
       iRoastingonePyjoneService.handlerPresserData(startDate,endDate);
       return ResultUtil.data("处理成功");
   }

   /** 功能描述:
   *处理检修 和正常数据部分的衔接部分
   * @return:
   * @Author: 杨春科
   * @Date: 2021-06-30 16:20
   * @Description //TODO
   */
   @ResponseBody
   @RequestMapping(method = RequestMethod.POST, value = "/handlerCurveData")
   public Result<String> handlerCurveData(String startDate,String endDate,Float mbt,String order) throws ParseException {
       iRoastingonePyjoneService.handlerCurveData(startDate,endDate,mbt,order);
       return ResultUtil.data("处理成功");
   }
}
